home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / pctj8411.arc / DISK2.ASM < prev    next >
Assembly Source File  |  1986-09-14  |  3KB  |  144 lines

  1. ;    disktest.asm - assembler functions for
  2. ;    disk I/O performance benchmark
  3. ;    assumes the small memory model is used
  4.  
  5. ;    compiler-dependent definitions
  6. ;    Lattice C version
  7. Pgroup    group    prog
  8. Dgroup    group    data
  9.     assume  cs:pgroup,ds:dgroup
  10. dstart    equ    dgroup
  11. Data    segment    word public 'DATA'
  12. Data    ends
  13. Prog    segment    byte public 'PROG'
  14. ;    end of Lattice C version
  15.  
  16.  
  17. ;    rawread(drive,nsec,begin_sec,buffer) - reads raw disk sectors
  18. ;        drive     = drive number 0=A  , 1=B ...
  19. ;        nsec      = number of sectors (512 bytes) to read
  20. ;        begin_sec = number of first logical sector to read
  21. ;        buffer    = store the data read here
  22. ;                (relative to DS)
  23.  
  24. ;    define the argument offsets relative to BP
  25. ;    old BP value is at zero
  26. ;    return address is at 2
  27. drive    equ    4
  28. nsec    equ    6
  29. begsec    equ    8
  30. buffer    equ    10
  31.  
  32.     public  rawread,rawread_,_rawread
  33. rawread:
  34. rawread_:
  35. _rawread:    push    bp
  36.     mov    bp,sp
  37.     push    bx
  38.     push    cx
  39.     push    dx
  40.     push    si
  41.     push    di
  42.     mov    ax,word ptr [bp+drive]
  43.     mov    cx,word ptr [bp+nsec]
  44.     mov    dx,word ptr [bp+begsec]
  45.     mov    bx,word ptr [bp+buffer]
  46.     int    25H        ; absolute disk read
  47.     pop    cx        ; discard original flags
  48.     pop    di
  49.     pop    si
  50.     pop    dx
  51.     pop    cx
  52.     pop    bx
  53.     jc    raw1        ; did the operation succeed ?
  54.     mov    ax,0        ;    yes - set ax=0
  55.     jmp    raw2
  56.                 ;    no  - force ax to be non-zero.
  57. raw1:
  58.     or    ax,ax        ; is AX already non-zero ?
  59.     jnz    raw2        ;    yes - just use it as an error return
  60.     mov    ax,255        ;    no  - fake a non-zero error return.
  61. raw2:
  62.     pop    bp
  63.     ret
  64.  
  65.  
  66. ;    get_ds()  - returns the data segment address
  67.     public get_ds,get_ds_
  68. get_ds:
  69. get_ds_:
  70. _get_ds:
  71.     mov    ax,ds
  72.     ret
  73.  
  74.  
  75. ;    long gettime() - returns time 
  76.     public    gettime,gettime_,_gettime
  77. gettime:
  78. gettime_:
  79. _gettime:
  80.     push    cx
  81.     push    dx
  82.     mov    ax,0        ; read clock function
  83.     int    1AH        ; time of day BIOS call    
  84. ;    now set up the return value
  85. ;    Lattice C version - long return = (AX-high , BX-low)
  86.     mov    ax,cx        ; move high order word to AX
  87.     mov    bx,dx        ; move low order word to BX
  88. ;    for C.I. C86 and others - long return = (DX-high , AX-low)
  89. ;    mov    ax,dx
  90. ;    mov    dx,cx
  91.     pop    dx
  92.     pop    cx
  93.     ret
  94.  
  95.  
  96. ;    getspac(ddrive,pfree,ptot,pbytes) - get disk free space info
  97. ;    ddrive - drive number ( 0=A , 1=B ... )
  98. ;    pfree - store no. free clusters here
  99. ;    ptot  - store no. clusters total here
  100. ;    pbytes- store number of bytes per sector here
  101. ;    returns no. sectors per cluster (or 0xFFFF for invalid drive)
  102.  
  103. ;    define argument offsets
  104. ;    old BP = 0
  105. ;    return address = 2
  106. ddrive    equ    4
  107. pfree    equ    6
  108. ptot    equ    8
  109. pbytes    equ    10
  110.  
  111.     public    getspac,getspac_,_getspac
  112. getspac:
  113. getspac_:
  114. _getspac:
  115.     push    bp
  116.     mov    bp,sp
  117.     push    bx
  118.     push    cx
  119.     push    dx
  120.     push    si
  121.     mov    dx,word ptr [bp+ddrive]
  122.     mov    ah,36H        ; PC-DOS get free space call
  123.     int    21H
  124.     mov    si,word ptr [bp+pfree] ; store free clusters value
  125.     mov    word ptr [si],bx
  126.     mov    si,word ptr [bp+ptot]  ; store total clusters value
  127.     mov    word ptr [si],dx
  128.     mov    si,word ptr [bp+pbytes] ; store bytes/sector value
  129.     mov    word ptr [si],cx
  130.                     ; sectors/cluster already in AX
  131.     pop    si        ; restore registers
  132.     pop    dx
  133.     pop    cx
  134.     pop    bx
  135.     pop    bp
  136.     ret
  137.  
  138. ;    compiler dependent stuff for end of code segment
  139. ;    Lattice C version
  140. Prog    ends
  141. ;    end of Lattice C version
  142.  
  143.     end
  144.